namespace Guan.CMS.Data.Migrations
{
    using System;
    using System.Data.Entity.Migrations;
    
    public partial class RemoveSEOTable : DbMigration
    {
        public override void Up()
        {
            DropForeignKey("dbo.Product", "SEO_Id", "dbo.SEOInfo");
            DropForeignKey("dbo.ProductCategory", "SEO_Id", "dbo.SEOInfo");
            DropForeignKey("dbo.Article", "SEOId", "dbo.SEOInfo");
            DropIndex("dbo.Product", new[] { "SEO_Id" });
            DropIndex("dbo.ProductCategory", new[] { "SEO_Id" });
            DropIndex("dbo.Article", new[] { "SEOId" });
            AddColumn("dbo.Product", "MetaKeywords", c => c.String());
            AddColumn("dbo.Product", "MetaDescription", c => c.String());
            AddColumn("dbo.Product", "MetaTitle", c => c.String());
            AddColumn("dbo.Product", "FriendlyName", c => c.String());
            AddColumn("dbo.ProductCategory", "MetaKeywords", c => c.String());
            AddColumn("dbo.ProductCategory", "MetaDescription", c => c.String());
            AddColumn("dbo.ProductCategory", "MetaTitle", c => c.String());
            AddColumn("dbo.ProductCategory", "FriendlyName", c => c.String());
            AddColumn("dbo.Article", "MetaKeywords", c => c.String());
            AddColumn("dbo.Article", "MetaDescription", c => c.String());
            AddColumn("dbo.Article", "MetaTitle", c => c.String());
            AddColumn("dbo.Article", "FriendlyName", c => c.String());
            DropColumn("dbo.Product", "SEO_Id");
            DropColumn("dbo.ProductCategory", "SEO_Id");
            DropColumn("dbo.Article", "SEOId");
            DropTable("dbo.SEOInfo");
        }
        
        public override void Down()
        {
            CreateTable(
                "dbo.SEOInfo",
                c => new
                    {
                        Id = c.Int(nullable: false, identity: true),
                        Keywords = c.String(maxLength: 500),
                        Description = c.String(maxLength: 1024),
                        Title = c.String(maxLength: 500),
                        FriendlyName = c.String(maxLength: 1024),
                    })
                .PrimaryKey(t => t.Id);
            
            AddColumn("dbo.Article", "SEOId", c => c.Int());
            AddColumn("dbo.ProductCategory", "SEO_Id", c => c.Int());
            AddColumn("dbo.Product", "SEO_Id", c => c.Int());
            DropColumn("dbo.Article", "FriendlyName");
            DropColumn("dbo.Article", "MetaTitle");
            DropColumn("dbo.Article", "MetaDescription");
            DropColumn("dbo.Article", "MetaKeywords");
            DropColumn("dbo.ProductCategory", "FriendlyName");
            DropColumn("dbo.ProductCategory", "MetaTitle");
            DropColumn("dbo.ProductCategory", "MetaDescription");
            DropColumn("dbo.ProductCategory", "MetaKeywords");
            DropColumn("dbo.Product", "FriendlyName");
            DropColumn("dbo.Product", "MetaTitle");
            DropColumn("dbo.Product", "MetaDescription");
            DropColumn("dbo.Product", "MetaKeywords");
            CreateIndex("dbo.Article", "SEOId");
            CreateIndex("dbo.ProductCategory", "SEO_Id");
            CreateIndex("dbo.Product", "SEO_Id");
            AddForeignKey("dbo.Article", "SEOId", "dbo.SEOInfo", "Id");
            AddForeignKey("dbo.ProductCategory", "SEO_Id", "dbo.SEOInfo", "Id");
            AddForeignKey("dbo.Product", "SEO_Id", "dbo.SEOInfo", "Id");
        }
    }
}
